//
//  BTEAlertViewController.swift
//  BTE
//
//  Created by Mike Zhang on 2025/8/18.
//

import UIKit

class BTEAlertViewController: UIViewController {
    
    let box = UIView()
    
    let mainv = UIView()
    
    let button = UIButton.init()
    
    let closeButton = UIButton.init()
    
    var action:(()->())?

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .colorWithHex("#000000",alpha: 0.5)
        
        view.addSubview(box)
        box.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(17)
            make.centerY.equalToSuperview()
        }
        
        box.addSubview(mainv)
        mainv.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
        }
        
        box.addSubview(button)
        button.setTitleColor(.white)
        button.setFont(.systemFont(ofSize: 18,weight: .bold))
        button.setTitle(title: BTELanguageManager.shared.localizedString(forKey: "Confirm"))
        button.setBackgroundColor(UIColor.colorWithHex("#39B4E6")!)
        button.roundCorners(.allCorners, radius: 25)
        button.layer.borderColor = UIColor.colorWithHex("#6C2724")!.cgColor
        button.layer.borderWidth = 3
        button.snp.makeConstraints { make in
            make.top.equalTo(mainv.snp.bottom).offset(20)
            make.bottom.equalToSuperview()
            make.centerX.equalToSuperview()
            make.height.equalTo(50)
            make.width.equalTo(215)
        }
        
        view.addSubview(closeButton)
        closeButton.setImage(image: UIImage.init(named: "Group 1171276714"))
        closeButton.snp.makeConstraints { make in
            make.right.top.equalTo(box)
        }
        
        button.addTarget(self, action: #selector(dosomething), for: .touchUpInside)
        closeButton.addTarget(self, action: #selector(closeAction), for: .touchUpInside)
    }
    
    @objc func dosomething(){
        action?()
    }

    @objc func closeAction(){
        dismiss(animated: false)
    }
   

}
